<?php
namespace Home\Controller;

use Think\Controller;

class BaseController extends Controller
{

    protected $nowxpay;
    protected $canUseWxPay;


    public function _initialize()
    {

//        session_start();

        // 如果是在微信里, 才走微信授权  授权就是执行
        if (!IS_AJAX) {

//            if($_GET['callback']){
//                dump($_SESSION);
//                exit();
//            }

            if (inWeixin() and empty($_SESSION['openid']) ) {
                new_wechat_auth('BLANK', $_SERVER['REQUEST_URI']);
            }
        }






        if (IS_GET) {
            // 是否支持微信支付
            $this->canUseWxPay = canUseWxPay();
            $this->assign('canUseWxPay', $this->canUseWxPay);

            // 强制不显示微信支付
//            $this->nowxpay = (I('get.t', '') == 'mp') ? 'mp' : '';
//            $this->assign('nowxpay', $this->nowxpay);
        }

        $inWeixin = false;
        if (inWeixin()) {
            $inWeixin = true;
        }
        $this->assign('inWeixin', $inWeixin);


    }
}


// end